<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <title>Atomic管理系统首页</title>
    <meta name="keywords" content="Atomic管理系统首页">
    <meta name="description" content="Atomic管理系统首页">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
    <link th:href="@{/favicon.ico}" rel="stylesheet"/>
    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
    <link th:href="@{/css/font-awesome.min.css}" rel="stylesheet"/>
    <link th:href="@{/css/animate.css}" rel="stylesheet"/>
    <link th:href="@{/css/style.css}" rel="stylesheet"/>
    <link th:href="@{/css/skins.css}" rel="stylesheet"/>
    <link th:href="@{/atomic/css/atomic-ui.css?v=3.3.0}" rel="stylesheet"/>
    <style type="text/css">
        #content-main.max {
            height: calc(100% - 110px);
            overflow: hidden;
            width: 100%;
            height: 100%;
            left: 0px;
            position: absolute;
            top: 0px;
            z-index: 9998;
            margin: 0;
        }

        .nav .logo {
            height: 60px;
        }
    </style>
</head>
<body class="fixed-sidebar full-height-layout gray-bg" style="overflow: hidden" th:classappend="${@config.getKey('sys.index.skinName')}">
<div id="wrapper">

        <!--左侧导航开始-->
        <nav class="navbar-default navbar-static-side navbar-left-menu" role="navigation">
            <div class="nav-close">
                <i class="fa fa-times-circle"></i>
            </div>
            <div class="sidebar-collapse">
                <ul class="nav" id="side-menu">
                    <li class="logo">
                        <span class="logo-lg">Atomic</span>
                    </li>
                    <li>
                        <div class="user-panel">
                            <a class="menuItem" title="个人中心" th:href="@{/system/user/profile}">
                                <div class="hide" th:text="个人中心"></div>
                                <div class="pull-left image">
                                    <img th:src="(${user.avatar} == '') ? @{/img/profile.jpg} : @{/profile/avatar/} + ${user.avatar}"
                                         class="img-circle" alt="User Image">
                                </div>
                            </a>
                            <div class="pull-left info">
                                <p>[[${user.loginName}]]</p>
                                <a href="#"><i class="fa fa-circle text-success"></i> 在线</a>
                                <a href="../logout" style="padding-left:5px;"><i class="fa fa-sign-out text-danger"></i>
                                    注销</a>
                            </div>
                        </div>
                    </li>
                    <li class="active">
                        <a href="index.html"><i class="fa fa-home"></i> <span class="nav-label">主页</span> <span
                                class="fa arrow"></span></a>
                        <ul class="nav nav-second-level">
                            <li class="active"><a class="menuItem" th:href="@{/system/main}">了解Atomic</a></li>
                        </ul>
                    </li>
                    <li th:each="menu : ${menus}" class="leftMenuLi leftMenus">
                        <a th:href="${menu.url}" th:if="${menu.menuType} eq 'C'" class="menuItem">
                            <i class="fa fa fa-bar-chart-o" th:class="${menu.icon}"></i>
                            <span class="nav-label" th:text="${menu.menuName}">一级菜单</span>
                        </a>
                        <a href="#" th:if="${menu.menuType} ne 'C'">
                            <i class="fa fa fa-bar-chart-o" th:class="${menu.icon}"></i>
                            <span class="nav-label" th:text="${menu.menuName}">一级菜单</span>
                            <span class="fa arrow"></span>
                        </a>
                        <ul class="nav nav-second-level collapse">
                            <li th:each="cmenu : ${menu.children}">
                                <a th:if="${#lists.isEmpty(cmenu.children)}" class="menuItem" th:text="${cmenu.menuName}" th:href="@{${cmenu.url}}">二级菜单</a>
                                <a th:if="${not #lists.isEmpty(cmenu.children)}" href="#">[[${cmenu.menuName}]]<span class="fa arrow"></span></a>
                                <ul th:if="${not #lists.isEmpty(cmenu.children)}" class="nav nav-third-level">
                                    <li th:each="emenu : ${cmenu.children}"><a class="menuItem" th:text="${emenu.menuName}" th:href="@{${emenu.url}}">三级菜单</a></li>
                                </ul>
                            </li>
                        </ul>
                    </li>
                </ul>
            </div>
        </nav>
        <!--左侧导航结束-->


    <!--右侧部分开始-->
    <div id="page-wrapper" class="gray-bg dashbard-1">
        <div class="row border-bottom">
            <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
                <div class="navbar-header" style="width:60px">
                    <a class="navbar-minimalize minimalize-styl-2" style="color:#FFF;" href="#" title="收起菜单">
                        <i class="fa fa-bars"></i>
                    </a>

                </div>
                <ul class="nav navbar-top-links navbar-left welcome-message" style="padding-left: -10px">
                    <li th:each="menu : ${sysMenus}">
                        <a th:title="${menu.menuName}" href="javascript:;" th:onclick="showNav([[${menu.menuId}]],[[${menu.menuName}]],[[${menu.url}]])"><i class="fa fa-cog" th:class="${menu.icon}"></i>&nbsp;[[${menu.menuName}]]</a>
                    </li>
                </ul>

                <ul class="nav navbar-top-links navbar-right welcome-message">
                    <li><a title="使用文档" href="javascript:;" target="_blank"><i class="fa fa-question-circle"></i>
                        使用文档</a></li>
                    <li><a title="全屏显示" id="fullScreen"><i class="fa fa-arrows-alt"></i> 全屏显示</a></li>
                    <li class="dropdown user-menu">
                        <a href="javascript:" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown">
                            <img th:src="(${user.avatar} == '') ? @{/img/profile.jpg} : @{/profile/avatar/} + ${user.avatar}"
                                 class="user-image">
                            <span class="hidden-xs">[[${user.userName}]]</span>
                        </a>
                        <ul class="dropdown-menu">
                            <li class="mt5">
                                <a th:href="@{/system/user/profile}" class="menuItem">
                                    <i class="fa fa-user"></i> 个人中心</a>
                            </li>
                            <li>
                                <a onclick="resetPwd()" class="menuItem">
                                    <i class="fa fa-key"></i> 修改密码</a>
                            </li>
                            <li class="divider"></li>
                            <li>
                                <a href="../logout">
                                    <i class="fa fa-sign-out"></i> 退出登录</a>
                            </li>
                        </ul>
                    </li>
                </ul>
            </nav>
        </div>
        <div class="row content-tabs">
            <button class="roll-nav roll-left tabLeft">
                <i class="fa fa-backward"></i>
            </button>
            <nav class="page-tabs menuTabs">
                <div class="page-tabs-content">
                    <a href="javascript:;" class="active menuTab" data-id="/system/main">首页</a>
                </div>
            </nav>
            <button class="roll-nav roll-right tabRight">
                <i class="fa fa-forward"></i>
            </button>
            <div class="btn-group roll-nav roll-right">
                <button class="dropdown J_tabClose" data-toggle="dropdown">
                    页签操作<span class="caret"></span>
                </button>
                <ul role="menu" class="dropdown-menu dropdown-menu-right">
                    <li><a class="tabCloseCurrent" href="javascript:void();">关闭当前</a></li>
                    <li><a class="tabCloseOther" href="javascript:void();">关闭其他</a></li>
                    <li><a class="tabCloseAll" href="javascript:void();">全部关闭</a></li>
                    <li><a class="tabMaxCurrent" href="javascript:void();">全屏显示</a></li>
                </ul>
            </div>
            <a href="#" class="roll-nav roll-right tabReload"><i class="fa fa-refresh"></i> 刷新</a>
        </div>

        <a id="ax_close_max" class="ax_close_max" href="#" title="关闭全屏"> <i class="fa fa-times-circle-o"></i> </a>

        <div class="row mainContent" id="content-main">
            <iframe class="Atomic_iframe" name="iframe0" width="100%" height="100%" data-id="/system/main"
                    th:src="@{/system/main}" frameborder="0" seamless></iframe>
        </div>
        <div class="footer">
            <div class="pull-right">© [[${copyrightYear}]] Atomic Copyright</div>
        </div>
    </div>
    <!--右侧部分结束-->
</div>
<!-- 全局js -->
<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<script th:src="@{/js/plugins/metisMenu/jquery.metisMenu.js}"></script>
<script th:src="@{/js/plugins/slimscroll/jquery.slimscroll.min.js}"></script>
<script th:src="@{/ajax/libs/blockUI/jquery.blockUI.js}"></script>
<script th:src="@{/ajax/libs/layer/layer.min.js}"></script>
<script th:src="@{/atomic/js/atomic-ui.js?v=3.3.0}"></script>
<script th:src="@{/atomic/js/common.js}"></script>
<script th:src="@{/atomic/index.js}"></script>
<script th:src="@{/ajax/libs/fullscreen/jquery.fullscreen.js}"></script>
<script type="text/javascript" th:src="@{/ajax/libs/juicer/juicer-min.js}"></script>
<script id="leftMenu_tpl" type="text/template">
    (@each list as it,index)
    <li class="leftMenuLi leftMenus">
        (@if it.menuType === 'C')
        <a class="menuItem" href="$(it.url)" data-index="$(index)">
            <i class="$(it.icon)"></i>
            <span class="nav-label">$(it.menuName)</span>
            (@if it.children.length >0)
            <span class="fa arrow"></span>
            (@/if)
        </a>
        (@else)
        <a href="$(it.url)" data-index="$(index)">
            <i class="$(it.icon)"></i>
            <span class="nav-label">$(it.menuName)</span>
            (@if it.children.length >0)
            <span class="fa arrow"></span>
            (@/if)
        </a>
        (@/if)

        (@if it.children.length >0)
        <ul class="nav nav-second-level collapse ">
            (@each it.children as sub2,index2)
            <li>
                (@if sub2.menuType === 'C')
                <a class="menuItem" href="$(sub2.url)" data-index="$(index2)">$(sub2.menuName)</a>
                (@else)
                <a href="$(sub2.url)" data-index="$(index2)">$(sub2.menuName)</a>(@if sub2.children.length >0)<span class="fa arrow"></span>(@/if)
                (@/if)

                <ul class="nav nav-third-level">
                    (@each sub2.children as sub3,index3)
                    <li><a class="menuItem" href="$(sub3.url)" data-index="$(index3)">$(sub3.menuName)</a></li>
                    (@/each)
                </ul>
            </li>
            (@/each)
        </ul>
        (@/if)
    </li>
    (@/each)
</script>
<script th:inline="javascript">
    var ctx = [[@{/}]];

        /*用户管理-重置密码*/
        function resetPwd() {
            var url = ctx + 'system/user/profile/resetPwd';
            $.modal.open("重置密码", url, '800', '500');
        }

        function showNav(id,menuName,url){
            //变更左导航菜单
            showSysMenu(id);
            //增加导航tab页
            createNav(id,menuName,url);
        }

        function createNav(id,menuName,url){
            if (id > 10000) {
                $('body').addClass("mini-navbar");
                $(".sidebar-collapse .logo").addClass("hide");
                var newName = menuName.substr(2,2);
                $.modal.openTab(newName+"导航", url)
            }else if (id <= 10000) {
                $('body').removeClass("mini-navbar");
                $(".sidebar-collapse .logo").removeClass("hide");
            }
        }

        function showSysMenu(id) {
            var urlStr = ctx + 'getSubSysMenuById/' + id;
            $.ajax({
                type: "GET",
                url: urlStr,
                dataType: "json",
                success: function (R) {
                    var data = new Object();
                    data.list = R.data;
                    juicer.set({
                        'tag::operationOpen': '(@',
                        'tag::operationClose': ')',
                        'tag::interpolateOpen': '$(',
                        'tag::interpolateClose': ')',
                        'tag::noneencodeOpen': '$$(',
                        'tag::noneencodeClose': ')',
                        'tag::commentOpen': '(#',
                        'tag::commentClose': ')'
                    });
                    var leftMenu_tpl = $("#leftMenu_tpl").html();
                    var leftMenu_compiled_tpl = juicer(leftMenu_tpl);

                    var html_leftMenu = leftMenu_compiled_tpl.render(data);
                    $(".leftMenus").remove();
                    $("#side-menu").append(html_leftMenu);
                    $('#side-menu').metisMenu();
                    $('.menuItem').on('click', menuItemTab1);
                },
                error: function () {

                }
            });
        }

        function menuItemTab1() {
            // 获取标识数据
            var dataUrl = $(this).attr('href'),
                dataIndex = $(this).data('index'),
                menuName = $.trim($(this).text()),
                flag = true;
            if (dataUrl == undefined || $.trim(dataUrl).length == 0) return false;

            // 选项卡菜单已存在
            $('.menuTab').each(function () {
                if ($(this).data('id') == dataUrl) {
                    if (!$(this).hasClass('active')) {
                        $(this).addClass('active').siblings('.menuTab').removeClass('active');
                        scrollToTab(this);
                        // 显示tab对应的内容区
                        $('.mainContent .Atomic_iframe').each(function () {
                            if ($(this).data('id') == dataUrl) {
                                $(this).show().siblings('.Atomic_iframe').hide();
                                return false;
                            }
                        });
                    }
                    flag = false;
                    return false;
                }
            });
            // 选项卡菜单不存在
            if (flag) {
                var str = '<a href="javascript:;" class="active menuTab" data-id="' + dataUrl + '">' + menuName + ' <i class="fa fa-times-circle"></i></a>';
                $('.menuTab').removeClass('active');

                // 添加选项卡对应的iframe
                var str1 = '<iframe class="Atomic_iframe" name="iframe' + dataIndex + '" width="100%" height="100%" src="' + dataUrl + '" frameborder="0" data-id="' + dataUrl + '" seamless></iframe>';
                $('.mainContent').find('iframe.Atomic_iframe').hide().parents('.mainContent').append(str1);

                $.modal.loading("数据加载中，请稍后...");

                $('.mainContent iframe:visible').load(function () {
                    $.modal.closeLoading();
                });

                // 添加选项卡
                $('.menuTabs .page-tabs-content').append(str);
                scrollToTab($('.menuTab.active'));
            }
            return false;
        }

        //滚动到指定选项卡
        function scrollToTab(element) {
            var marginLeftVal = calSumWidth($(element).prevAll()),
                marginRightVal = calSumWidth($(element).nextAll());
            // 可视区域非tab宽度
            var tabOuterWidth = calSumWidth($(".content-tabs").children().not(".menuTabs"));
            //可视区域tab宽度
            var visibleWidth = $(".content-tabs").outerWidth(true) - tabOuterWidth;
            //实际滚动宽度
            var scrollVal = 0;
            if ($(".page-tabs-content").outerWidth() < visibleWidth) {
                scrollVal = 0;
            } else if (marginRightVal <= (visibleWidth - $(element).outerWidth(true) - $(element).next().outerWidth(true))) {
                if ((visibleWidth - $(element).next().outerWidth(true)) > marginRightVal) {
                    scrollVal = marginLeftVal;
                    var tabElement = element;
                    while ((scrollVal - $(tabElement).outerWidth()) > ($(".page-tabs-content").outerWidth() - visibleWidth)) {
                        scrollVal -= $(tabElement).prev().outerWidth();
                        tabElement = $(tabElement).prev();
                    }
                }
            } else if (marginLeftVal > (visibleWidth - $(element).outerWidth(true) - $(element).prev().outerWidth(true))) {
                scrollVal = marginLeftVal - $(element).prev().outerWidth(true);
            }
            $('.page-tabs-content').animate({
                    marginLeft: 0 - scrollVal + 'px'
                },
                "fast");
        }

        //计算元素集合的总宽度
        function calSumWidth(elements) {
            var width = 0;
            $(elements).each(function() {
                width += $(this).outerWidth(true);
            });
            return width;
        }
</script>
</body>
</html>
